package cn.iocoder.yudao.module.nginxui.dal.mysql.httplocation;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.nginxui.dal.dataobject.httpconfig.HttpConfigDO;
import cn.iocoder.yudao.module.nginxui.dal.dataobject.httplocation.HttpLocationDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.nginxui.controller.admin.httplocation.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * Nginx Server下的Location块配置 Mapper
 *
 * @author HuangJunZhong
 */
@Mapper
public interface HttpLocationMapper extends BaseMapperX<HttpLocationDO> {

    default PageResult<HttpLocationDO> selectPage(HttpLocationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HttpLocationDO>()
                .eqIfPresent(HttpLocationDO::getServerId, reqVO.getServerId())
                .eqIfPresent(HttpLocationDO::getPath, reqVO.getPath())
                .eqIfPresent(HttpLocationDO::getRoot, reqVO.getRoot())
                .eqIfPresent(HttpLocationDO::getProxyPass, reqVO.getProxyPass())
                .eqIfPresent(HttpLocationDO::getTryFiles, reqVO.getTryFiles())
                .eqIfPresent(HttpLocationDO::getRewrite, reqVO.getRewrite())
                .eqIfPresent(HttpLocationDO::getAllow, reqVO.getAllow())
                .eqIfPresent(HttpLocationDO::getDeny, reqVO.getDeny())
                .eqIfPresent(HttpLocationDO::getExtraLocationConfig, reqVO.getExtraLocationConfig())
                .eqIfPresent(HttpLocationDO::getSort, reqVO.getSort())
                .eqIfPresent(HttpLocationDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(HttpLocationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HttpLocationDO::getId));
    }
    List<HttpLocationDO> selectByServerIdAndStatus(
            @Param("serverId") Long serverId,
            @Param("status") Integer status
    );
}